﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using AnyOffice.DAL;
using AnyOffice.Components;

namespace AnyOffice.Web.general.system.netdiskGX
{
    public partial class NDiskType : BasePage
    {
        public readonly DiskTypeGXDao dt = new DiskTypeGXDao();

        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                Bind();
            }
        }

        public void Bind()
        {
            rep_disktype.DataSource = dt.GetList(base.Conn,string.Empty);
            this.DataBind();
        }

       

       
        protected void rep_disktype_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            LinkButton lbt =(LinkButton) e.Item.FindControl("lbtn_del");
            if (e.CommandName == "edit")
            {
                Response.Redirect("NDiskTypeForm.aspx?DiskTypeID=" + e.CommandArgument.ToString());
            }
            if (e.CommandName == "del")
            {
                dt.Delete(base.Conn, Convert.ToInt32(e.CommandArgument.ToString()));
                if (Directory.Exists(lbt.CssClass))
                {
                    Directory.Delete(lbt.CssClass, true);
                }
                Bind();
            }
        }

        protected void rep_disktype_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            Label ltype = (Label)e.Item.FindControl("lblfiletype");
            if (ltype.Text == Public_foldGX.DiskTypeName || ltype.Text == Public_foldGX.DiskTypeName2)
            {
                LinkButton b = (LinkButton)e.Item.FindControl("lbtn_del");
                b.Visible = false;
            }

        }

      

  
    }
}